package com.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.common.utils.DateUtil;
import com.common.utils.Result;
import com.entity.TaskRecord;
import com.mapper.TaskRecordMapper;
import com.service.TaskRecordService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wty
 * @since 2021-03-18
 */
@Service
public class TaskRecordServiceImpl extends ServiceImpl<TaskRecordMapper, TaskRecord> implements TaskRecordService {

    /**
     * 根据条件获取任务数据
     * @param taskRecord
     * @return
     */
    @Override
    public Result getTaskDataByTaskId(TaskRecord taskRecord) {
        Integer taskId = taskRecord.getTaskId();
        String addTime = taskRecord.getAddTime();

        Wrapper<TaskRecord> wr=new EntityWrapper<>();
        wr.eq("task_id",taskId);

        if(StringUtils.isEmpty(addTime)){
            addTime= DateUtil.getDate_yyyyMMdd();
        }
        wr.eq("add_time",addTime);
        TaskRecord taskRecordOne = this.selectOne(wr);
        return Result.success(taskRecordOne);
    }
}
